import { beforeAll, describe, test, expect } from 'vitest';
import { DbContext } from '~/core/db';

let dbContext: DbContext;
beforeAll(() => {
    dbContext = new DbContext({
        gremlin: {
            host: 'localhost',
            port: 8182,
            batchSize: 1000,
        },
    });
})

describe('ConnectionTest', () => {
    test('ConnectionTest_001', async () => {
        const g = dbContext.getGremlinConnection().g();
        await g.V().drop().iterate();
        const result1 = await g.V().count().next();
        expect(result1.value).toBe(0);
        const result2 = await g.E().count().next();
        expect(result2.value).toBe(0);
    });

    test('ConnectionTest_002', async () => {
        const g = dbContext.getGremlinConnection().g();
        await g.V().drop().iterate();
        for (let i = 0; i < 5; i++) {
            await g.addV('person').property('name', 'jason').next();
        }
        const result1 = await g.V().count().next();
        expect(result1.value).toBe(5);
    });
})
